/*
 *  Real - a set querying language
 *  
 
 Here sets are constructed and manipulated. Set construction is done by a separate 
 microlanguage.
  
 */
 
grammar RealSetQuery;
 
options {
  language=Java;
  output = AST;
  ASTLabelType=CommonTree;
  k=4;  
}

 
tokens {
  QUESTION = '?';
  SEMICOLON = ';';  
  LCURLY = '{';
  RCURLY = '}';
  NEWLINE = '\n';
 }

@header {
 package real;
  
 import real.lang.*;
 import real.evaluation.*;
}

@lexer::header {
 package real;
}
 
query returns [RealQuery result]
  : 
  statements? set QUESTION EOF
  
  /* creater RealQuery object and return it as a result */
  {
  RealQuery rq = new RealQuery();
  $result = rq;
  }
  ;

statements
  : (expression SEMICOLON| expression NEWLINE)+;
 
expression  : assignment;

assignment  : ID ASSIGN value;

value : constant | set;

constant  : INT |  STRING;

set : ID | set_constr;

set_constr  : 
  LCURLY
  /*
    * Now we should call for parsing of embended 
    * microlanguage for set construction     
    */
    {
    
    }
  ;
 
ASSIGN  : '=';
 
STRING  : '"' .* '"' ;
 
INT :   '0'..'9'+ ;
ID    :   ('_'|'a'..'z'|'A'..'Z') ('_'|'a'..'z'|'A'..'Z'|'0'..'9')* ; 
WS    :   (' '|'\t')+ {$channel=HIDDEN;} ;
CMT   :   '/*' .* '*/'     {$channel=HIDDEN;} ;
